<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="css/iconfont.css">
<link rel="stylesheet" href="css/global.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/swiper.min.css">
<link rel="stylesheet" href="css/styles.css">
<script src="js/jquery.1.12.4.min.js" charset="UTF-8"></script>
<script src="js/bootstrap.min.js" charset="UTF-8"></script>
<script src="js/swiper.min.js" charset="UTF-8"></script>
<script src="js/global.js" charset="UTF-8"></script>
<script src="js/jquery.DJMask.2.1.1.js" charset="UTF-8"></script>
<title>U袋网</title>
<!-- 引入layui样式和脚本 -->
<link rel="stylesheet" href="../admin/layui/css/layui.css">
<script src="../admin/layui/layui.js"></script>
<script src="js/jquery.js"></script>
<script src="js/md5.js"></script>
</head>
<body>
	<!-- 引入个人中心头部 -->
	<jsp:include page="user-header.jsp"></jsp:include>
    <!--MD5加密-->
    <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.js"></script>
	<div class="content clearfix bgf5">
		<section class="user-center inner clearfix">
			<!-- 引入左侧导航栏 -->
			<jsp:include page="pull-left-bgf.jsp"></jsp:include>
			<div class="pull-right">
				<div class="user-content__box clearfix bgf">
					<div class="title">账户信息-修改登陆密码</div>
			  
					<div class="step-flow-box">
					 <c:if test="${ empty USER_SESSION}">
				       <h3>您还没有登录呦~</h3>
			         </c:if>
			         <c:if test="${ not empty USER_SESSION}">
						<form action="" class="user-setting__form layui-form"
							method="post" role="form" id="updatePwdFrom">
							<div class="form-group">
								<input class="form-control" name="oldpassword" required=""
									maxlength="11" autocomplete="off" type="password" id="oldpassword"> <span
									class="tip-text">请输入原密码</span> <span class="see-pwd pwd-toggle"
									title="显示密码"><i class="glyphicon glyphicon-eye-open"></i></span>
								<span class="error_tip"></span>
							</div>
							<div class="form-group">
								<input class="form-control" name="newPassword" required=""
									minlength="6" maxlength="12" autocomplete="off" type="password"
									id="newPassword"> <span class="tip-text">新的密码</span> <span
									class="see-pwd pwd-toggle" title="显示密码"><i
									class="glyphicon glyphicon-eye-open"></i></span> <span
									class="error_tip"></span>
							</div>
							<div class="form-group">
								<div class="form-group">
									<input class="form-control" name="rePassword" required=""
										minlength="6" maxlength="11" autocomplete="off"
										type="password" id="renewpass"> <span class="tip-text">再次确认新的密码</span>
									<span class="see-pwd pwd-toggle" title="显示密码"><i
										class="glyphicon glyphicon-eye-open"></i></span> <span
										class="error_tip"></span>
								</div>
							</div>
							<div class="user-form-group tags-box">
								<button type="submit" class="btn" lay-submit
									lay-filter="subBtnUpdate">提交</button>
							</div>
							<script src="js/login.js"></script>
							<script>
								$(document).ready(
									function() {
										$('.form-control').on('blur focus',
												function() {
													$(this).addClass('focus')
													if ($(this).val() == '') {
														$(this).removeClass('focus')
															}
														});
												});
							</script>
						</form>
                    </c:if>
						<script>
							layui.use([ 'form', 'layer' ], function() {
								var form = layui.form;
								var $ = layui.$;
								var layer = layui.layer;

								//表单提交
								form.on('submit(subBtnUpdate)', function(data) {
									//var formData=$("#updatePwdFrom").serialize();
									var renewpass=$("#renewpass").val();
									var newPassword=$('#newPassword').val();
									var oldpassword=$('#oldpassword').val();
									var url="updDengPwdPhone";
										$.post(url, {"oldpassword":md5(oldpassword),"rePassword":md5(renewpass),"newPassword":md5(newPassword)}, function(res) {
											console.log(res);
											if (res.code == 0) {
												layer.msg(res.msg, {
													time : 3000
												}, function() {
													layer.closeAll();//关闭所有窗口
													window.location.reload();
													window.location.href="login.jsp";
												})
											} else {
												layer.msg(res.msg, {
													time : 2000
												}, function() {
													layer.closeAll();//关闭所有窗口
												})
											}
										}, "json")
									return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
								});

							});
						 </script>
                       </div>
					</div>
				</div>
		</section>
	</div>
	<!-- 引入右侧菜单 -->
	<jsp:include page="right-nav.jsp"></jsp:include>
	<!-- 底部信息 -->
	<!-- 引入脚部 -->
	<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>